package com.friday.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.friday.bo.SignInOutBo;
import com.friday.bo.impl.SignInOutBoImpl;

public class SignInServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		System.out.println("SignInServlet");
		HttpSession session = request.getSession();
		String account = (String)session.getAttribute("account");
		SignInOutBo bo = new SignInOutBoImpl();
		
		try {
			int ret = bo.signIn(account);
			if(ret > 0) {
				session.setAttribute("signstate", 1);
				response.sendRedirect("MyCheckIn.jsp");
			}
			else {
				response.sendRedirect("MyCheckIn.jsp");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
